<?php

use think\migration\Migrator;
use think\migration\db\Column;

class ReportDriverDelivery extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('report_driver_delivery', ['engine' => 'InnoDB', 'comment' => '司机配送报表', 'signed' => false]);
        $table->addColumn('company_id', 'integer', ['default' => 0, 'limit' => 10, 'comment' => '公司id', 'signed' => false])
              ->addColumn('driver_id', 'integer', ['default' => 0, 'limit' => 10, 'comment' => '司机id', 'signed' => false])
              ->addColumn('store_num', 'integer', ['default' => 0, 'limit' => 10, 'comment' => '配送门店数', 'signed' => false])
              // 商品重量
              ->addColumn('goods_weight', 'decimal', ['default' => 0, 'precision' => 10, 'scale' => 2, 'comment' => '商品重量', 'signed' => false])
            // 商品体积
              ->addColumn('goods_volume', 'decimal', ['default' => 0, 'precision' => 10, 'scale' => 2, 'comment' => '商品体积', 'signed' => false])
            // 订单金额
              ->addColumn('order_amount', 'decimal', ['default' => 0, 'precision' => 10, 'scale' => 2, 'comment' => '订单金额', 'signed' => false])
            // 货值金额
              ->addColumn('goods_value', 'decimal', ['default' => 0, 'precision' => 10, 'scale' => 2, 'comment' => '货值金额', 'signed' => false])
            // 配送提成
              ->addColumn('delivery_commission', 'decimal', ['default' => 0, 'precision' => 10, 'scale' => 2, 'comment' => '配送提成', 'signed' => false])
            // 应收金额
              ->addColumn('receivable_amount', 'decimal', ['default' => 0, 'precision' => 10, 'scale' => 2, 'comment' => '应收金额', 'signed' => false])
            // 实收金额
              ->addColumn('received_amount', 'decimal', ['default' => 0, 'precision' => 10, 'scale' => 2, 'comment' => '实收金额', 'signed' => false])
                // 统计时间天
                ->addColumn('time', 'date', ['comment' => '统计时间天'])
            ->addIndex('company_id')
            ->addIndex('driver_id')
            ->addIndex('time')
            ->save();
    }
}
